import requests

class BaseRequests:
    def __init__(self):
        self.session = requests.session()

    def get(self,url,**kwargs):
        try:
            r = self.session.get(url,**kwargs)
            print(f"发送get请求,url:{url},参数：{kwargs}")
            return r
        except Exception as e:
            print(f"发送get请求失败，url:{url},参数:{kwargs},异常信息:{e}")

    def post(self, url, **kwargs):
        try:
            r = self.session.post(url, **kwargs)
            print(f"发送post请求,url:{url},参数：{kwargs}")
            return r
        except Exception as e:
            print(f"发送post请求失败，url:{url},参数:{kwargs},异常信息:{e}")

if __name__ == '__main__':
    br = BaseRequests()
    br.get("http://www.httpbin.org/get?username=admin")
    canshu = {"username":"admin","pwd":"123456"}
    br.post("http://www.httpbin.org/post",data=canshu)

